/***************************************************************************\
 * Copyright (C) by Keio University
 * Pyramid.hpp created in 02 2012.
 * Mail : fdesorbi@hvrl.ics.keio.ac.jp
 *
 * Pyramid.hpp is part of the HVRL Engine Project.
 *
 * The HVRL Engine Project is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * The HVRL Engine Project is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 \***************************************************************************/

#ifndef PYRAMID_HPP__
#define PYRAMID_HPP__

#include <opencv2/opencv.hpp>

namespace hvrl {

/**
 * \brief Class a pyramid image (multi-resolution image container)
 * \author Francois de Sorbier
 */
class Pyramid {

private:

	unsigned int levels; ///< Number of levels in the pyramid

	cv::Size smoothingparameter; ///< Size of the gaussian kernel applied at level 0

	float subsamplingfactor; ///< The sub sampling factor applied at each new level

	cv::Mat * pyramid; ///< The pyramid of images

public:

	/**
	 * The default constuctor
	 */
	Pyramid(void);

	/**
	 * Constuctor
	 * \param inputimage the input image that will be at the level 0 of the pyramid
	 * \param levels the number of levels that the pyramid will contain
	 * \param ssfactor the subsampling factor that should be applied at each level
	 * \param smoothing the size of the gaussian kernel initially applied at the level 0
	 */
	Pyramid(const cv::Mat& inputimage, const unsigned int& levels, const float& ssfactor = 0.5, const cv::Size& smoothing = cv::Size(0,0));

	/**
	 * The destructor
	 */
	~Pyramid(void);

	/**
	 * The method initialize the pyramid according to the given parameters
	 *
	 * The sub-sampling factor may change if it does not correspond to a possible parameter when applied to the input image
	 *
	 * If the size of the smoothing kernel is NULL then no smoothing will be applied
	 *
	 * \param inputimage the input image that will be at the level 0 of the pyramid
	 * \param levels the number of levels that the pyramid will contain
	 * \param ssfactor the subsampling factor that should be applied at each level
	 * \param smoothing the size of the gaussian kernel initially applied at the level 0
	 *
	 * \return true if the creation of the pyramid was successful
	 */
	bool init(const cv::Mat& inputimage, const unsigned int& levels, const float& ssfactor, const cv::Size& smoothing);

	bool update(const cv::Mat& inputimage);

	const cv::Mat& getLevel(const unsigned int& level);

	const unsigned int& getLevels(void);

	const float& getSubSamplingFactor(void);



};

}


#endif
